<?php
namespace app\html\controller;
// use app\index\
class Teamer extends Base
{
    public function index()
    {      
        $id=request()->param('id');   
        $viewPage=$this->getIndexPage($id);    
        $photo=db("cms_teamer");
        $channel=db("channel");
        $fname=$channel->where("id",$id)->value("name");  
        $pid=$channel->where("id=".$id)->value("pid");
        if($pid > 0){
            $gcid=$pid;
            $pcid=$id;            
            $lchannel=$this->get_left_channel($gcid);     
            $gnavName=$channel->where("id=".$gcid)->value("name");            
            $pnavName=$channel->where("id=".$pcid)->value("name");
        }else{
            $gcid=$id;
            // $lchannel=$this->get_left_channel($id);
            $gnavName=$channel->where("id=".$gcid)->value("name");
        }
        $where['status']=1;
        $where['cid']=$id;
        $mess=$photo->where($where)->order("is_top desc,sort asc , id DESC")->select();
        for ($i=0; $i < count($mess); $i++) {       

            $mess[$i]['content']=html_entity_decode($mess[$i]['content']);
        }
           
        // SEO META关键字配置
        $meta=$this->getSeoMeta($gnavName,$pnavName);
        $this->assign("meta",$meta);
        $modelx=$channel->where("id",$id)->value("modelx");
        $modelxMark=db("modelx")->where("id=".$modelx)->value("mark");
        $this->assign("modelxMark",$modelxMark);

        $banner=$this->get_banner($gcid);
        $this->assign("banner",$banner);
        $this->assign("pnavName",$pnavName);
        $this->assign("gnavName",$gnavName);
        $this->assign("lchannel",$lchannel);
        $this->assign("cid",$cid);
        $this->assign("gcid",$gcid);
        $this->assign("pcid",$pcid);
        $this->assign("fname",$fname);
        $this->assign("mess",$mess);
        return view($viewPage);
    }  
    public function detail()
    {
        $id=request()->param('id');       
        $photo=db("cms_teamer");
        $channel=db("channel");

        $mess=$photo->find($id);
        // html_entity_decode 把HTML 实体转换回字符
        // htmlentities 把字符转换为 HTML 实体
        // htmlspecialchars 把预定义的字符转换为 HTML 实体
        $mess['content']=html_entity_decode($mess['content']);
        $viewPage=$this->getDetailPage($mess['cid']);  

        $pid=$channel->where("id=".$mess['cid'])->value("pid");
        if($pid > 0){
            $gcid=$pid;
            $pcid=$mess['cid'];            
            $lchannel=$this->get_left_channel($gcid);     
            $gnavName=$channel->where("id=".$gcid)->value("name");            
            $pnavName=$channel->where("id=".$pcid)->value("name");
        }else{
            $gcid=$mess['cid'];
            // $lchannel=$this->get_left_channel($id);
            $gnavName=$channel->where("id=".$gcid)->value("name");
        }

             
        
        $fname=$channel->where("id",$mess['cid'])->value("name");

        // SEO META关键字配置
        $meta=$this->getSeoMeta($gnavName,$pnavName,$mess);
        $this->assign("meta",$meta);

        $modelx=$channel->where("id",$mess['cid'])->value("modelx");
        $modelxMark=db("modelx")->where("id=".$modelx)->value("mark");
        $this->assign("modelxMark",$modelxMark);
        $banner=$this->get_banner($gcid);
        $this->assign("banner",$banner);
        $this->assign("pnavName",$pnavName);
        $this->assign("gnavName",$gnavName);
        $this->assign("lchannel",$lchannel);
        $this->assign("pcid",$pcid);
        $this->assign("gcid",$gcid);
        $this->assign("fname",$fname);
        $this->assign("mess",$mess);
        return view($viewPage);
    }  
}
